package com.niit.service.impl;

import com.niit.dao.ProductMapper;
import com.niit.pojo.Product;
import com.niit.pojo.ProductView;
import com.niit.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<ProductView>  productList() {

        return productMapper.productList();
    }

    @Override
    public int addProduct(Product product) {

        return productMapper.insertProduct(product);
    }

    @Override
    public int deleteProductById(int product_id) {
        return productMapper.removeProductById(product_id);
    }

    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public List<ProductView> selectProduct(String input) {
        System.out.println(input);
        return productMapper.selectProduct(input);
    }

    @Override
    public Product selectProductById(int id) {
        return productMapper.selectProductById(id);
    }

    @Override
    public ProductView selectProductViewById(int id) {
        return productMapper.selectProductViewById(id);
    }
}
